<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\model\mongo;

use app\enum\CdcEnum;

abstract class MongoAppendSyncModel extends MongoSyncModel
{
    /**
     * 获取删除字段.
     */
    public function getDeleteFields(): string
    {
        if ($this->getAttr('type') == CdcEnum::STAT_ACCOUNT) {// 账户
            return 'account_id';
        }
        if ($this->getAttr('type') == CdcEnum::STAT_CLIENT) {// 客户
            return 'client_id';
        }
        if ($this->getAttr('type') == CdcEnum::STAT_KS_USER_VIDEO) {// KsUserId
            return 'user_id';
        }
        return '';
    }

    /**
     * 获取汇总查询字段.
     */
    public function getStatField(): array
    {
        $fields = ['video_id'];
        if ($this->getAttr('type') == CdcEnum::STAT_ACCOUNT) {
            $fields[] = 'account_id';
        } elseif ($this->getAttr('type') == CdcEnum::STAT_CLIENT) {
            $fields[] = 'client_id';
        } elseif ($this->getAttr('type') == CdcEnum::STAT_KS_USER_VIDEO) {
            $fields[] = 'user_id';
        }

        return $fields;
    }

    /**
     * 删除字段.
     * @return array|string[]
     */
    public function getDelField(): array
    {
        return [
            'account_id',
        ];
    }
}
